package com.zack.xjht.db.gen;

import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import org.greenrobot.greendao.query.Query;
import org.greenrobot.greendao.query.QueryBuilder;

import com.zack.xjht.entity.UrgentGetListBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "URGENT_GET_LIST_BEAN".
*/
public class UrgentGetListBeanDao extends AbstractDao<UrgentGetListBean, Long> {

    public static final String TABLENAME = "URGENT_GET_LIST_BEAN";

    /**
     * Properties of entity UrgentGetListBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property UId = new Property(0, Long.class, "uId", true, "_id");
        public final static Property GunCabinetLocationId = new Property(1, String.class, "gunCabinetLocationId", false, "GUN_CABINET_LOCATION_ID");
        public final static Property ObjectId = new Property(2, String.class, "objectId", false, "OBJECT_ID");
        public final static Property OutObjectNumber = new Property(3, int.class, "outObjectNumber", false, "OUT_OBJECT_NUMBER");
        public final static Property LocationType = new Property(4, String.class, "locationType", false, "LOCATION_TYPE");
        public final static Property GunNo = new Property(5, String.class, "gunNo", false, "GUN_NO");
        public final static Property LocationNo = new Property(6, int.class, "locationNo", false, "LOCATION_NO");
        public final static Property TaskGetId = new Property(7, Long.class, "taskGetId", false, "TASK_GET_ID");
        public final static Property ObjectType = new Property(8, String.class, "objectType", false, "OBJECT_TYPE");
        public final static Property UrgentTaskListId = new Property(9, String.class, "urgentTaskListId", false, "URGENT_TASK_LIST_ID");
    }

    private Query<UrgentGetListBean> urgentOutBean_UrgentGetListQuery;

    public UrgentGetListBeanDao(DaoConfig config) {
        super(config);
    }
    
    public UrgentGetListBeanDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"URGENT_GET_LIST_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: uId
                "\"GUN_CABINET_LOCATION_ID\" TEXT," + // 1: gunCabinetLocationId
                "\"OBJECT_ID\" TEXT," + // 2: objectId
                "\"OUT_OBJECT_NUMBER\" INTEGER NOT NULL ," + // 3: outObjectNumber
                "\"LOCATION_TYPE\" TEXT," + // 4: locationType
                "\"GUN_NO\" TEXT," + // 5: gunNo
                "\"LOCATION_NO\" INTEGER NOT NULL ," + // 6: locationNo
                "\"TASK_GET_ID\" INTEGER," + // 7: taskGetId
                "\"OBJECT_TYPE\" TEXT," + // 8: objectType
                "\"URGENT_TASK_LIST_ID\" TEXT);"); // 9: urgentTaskListId
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"URGENT_GET_LIST_BEAN\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, UrgentGetListBean entity) {
        stmt.clearBindings();
 
        Long uId = entity.getUId();
        if (uId != null) {
            stmt.bindLong(1, uId);
        }
 
        String gunCabinetLocationId = entity.getGunCabinetLocationId();
        if (gunCabinetLocationId != null) {
            stmt.bindString(2, gunCabinetLocationId);
        }
 
        String objectId = entity.getObjectId();
        if (objectId != null) {
            stmt.bindString(3, objectId);
        }
        stmt.bindLong(4, entity.getOutObjectNumber());
 
        String locationType = entity.getLocationType();
        if (locationType != null) {
            stmt.bindString(5, locationType);
        }
 
        String gunNo = entity.getGunNo();
        if (gunNo != null) {
            stmt.bindString(6, gunNo);
        }
        stmt.bindLong(7, entity.getLocationNo());
 
        Long taskGetId = entity.getTaskGetId();
        if (taskGetId != null) {
            stmt.bindLong(8, taskGetId);
        }
 
        String objectType = entity.getObjectType();
        if (objectType != null) {
            stmt.bindString(9, objectType);
        }
 
        String urgentTaskListId = entity.getUrgentTaskListId();
        if (urgentTaskListId != null) {
            stmt.bindString(10, urgentTaskListId);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, UrgentGetListBean entity) {
        stmt.clearBindings();
 
        Long uId = entity.getUId();
        if (uId != null) {
            stmt.bindLong(1, uId);
        }
 
        String gunCabinetLocationId = entity.getGunCabinetLocationId();
        if (gunCabinetLocationId != null) {
            stmt.bindString(2, gunCabinetLocationId);
        }
 
        String objectId = entity.getObjectId();
        if (objectId != null) {
            stmt.bindString(3, objectId);
        }
        stmt.bindLong(4, entity.getOutObjectNumber());
 
        String locationType = entity.getLocationType();
        if (locationType != null) {
            stmt.bindString(5, locationType);
        }
 
        String gunNo = entity.getGunNo();
        if (gunNo != null) {
            stmt.bindString(6, gunNo);
        }
        stmt.bindLong(7, entity.getLocationNo());
 
        Long taskGetId = entity.getTaskGetId();
        if (taskGetId != null) {
            stmt.bindLong(8, taskGetId);
        }
 
        String objectType = entity.getObjectType();
        if (objectType != null) {
            stmt.bindString(9, objectType);
        }
 
        String urgentTaskListId = entity.getUrgentTaskListId();
        if (urgentTaskListId != null) {
            stmt.bindString(10, urgentTaskListId);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public UrgentGetListBean readEntity(Cursor cursor, int offset) {
        UrgentGetListBean entity = new UrgentGetListBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // uId
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // gunCabinetLocationId
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // objectId
            cursor.getInt(offset + 3), // outObjectNumber
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // locationType
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // gunNo
            cursor.getInt(offset + 6), // locationNo
            cursor.isNull(offset + 7) ? null : cursor.getLong(offset + 7), // taskGetId
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // objectType
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9) // urgentTaskListId
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, UrgentGetListBean entity, int offset) {
        entity.setUId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setGunCabinetLocationId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setObjectId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setOutObjectNumber(cursor.getInt(offset + 3));
        entity.setLocationType(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setGunNo(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setLocationNo(cursor.getInt(offset + 6));
        entity.setTaskGetId(cursor.isNull(offset + 7) ? null : cursor.getLong(offset + 7));
        entity.setObjectType(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setUrgentTaskListId(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(UrgentGetListBean entity, long rowId) {
        entity.setUId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(UrgentGetListBean entity) {
        if(entity != null) {
            return entity.getUId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(UrgentGetListBean entity) {
        return entity.getUId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
    /** Internal query to resolve the "urgentGetList" to-many relationship of UrgentOutBean. */
    public List<UrgentGetListBean> _queryUrgentOutBean_UrgentGetList(Long taskGetId) {
        synchronized (this) {
            if (urgentOutBean_UrgentGetListQuery == null) {
                QueryBuilder<UrgentGetListBean> queryBuilder = queryBuilder();
                queryBuilder.where(Properties.TaskGetId.eq(null));
                urgentOutBean_UrgentGetListQuery = queryBuilder.build();
            }
        }
        Query<UrgentGetListBean> query = urgentOutBean_UrgentGetListQuery.forCurrentThread();
        query.setParameter(0, taskGetId);
        return query.list();
    }

}
